package com.demo.mdmt.impl;

import com.demo.api.user.service.QueryLimitService;
import com.demo.common.enums.ResultCode;
import com.demo.common.response.Result;
import com.demo.mdmt.domain.TestLimit;
import com.demo.mdmt.mapper.TestLimitDao;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *
 * @author luoguoqiang
 * @since
 */
@Service(version = "1.0.0", interfaceClass = QueryLimitService.class, timeout = 120000, retries = 3)
@Slf4j
public class QueryLimitServiceImpl implements QueryLimitService {
  @Autowired
  TestLimitDao testLimitDao;

  @Override
  public Result queryById(Integer id) {
    log.info("QueryLimitServiceImpl.queryById 执行查询，参数{}", id);
    TestLimit testLimitDO = null;
    try {
      testLimitDO = testLimitDao.selectById(id);
    } catch (Exception e){
      log.info("{}", e);
      return Result.fail(ResultCode.SYSTEM_ERROR);
    }
    log.info("QueryLimitServiceImpl.queryById 查询正常结束，参数{}", id);
    return Result.suc(toAipTestLimit(testLimitDO));
  }

  protected com.demo.api.user.domain.TestLimit toAipTestLimit(TestLimit testLimit){
    com.demo.api.user.domain.TestLimit testLimitApi = new com.demo.api.user.domain.TestLimit();
    BeanUtils.copyProperties(testLimit, testLimitApi);
    return testLimitApi;
  }
}
